<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>1.以下表达式的计算结果为？（选择一项） |  zfy的个人博客</title>
    <meta name="generator" content="VuePress 1.9.7">
    <link rel="icon" href="./img/Scorpio.png">
    <link rel="stylesheet" href="./css/style.css">
    <meta name="description" content="My tech blog">
    
    <link rel="preload" href="./assets/css/0.styles.cfdaa54c.css" as="style"><link rel="preload" href="./assets/js/app.7878252f.js" as="script"><link rel="preload" href="./assets/js/2.877879cc.js" as="script"><link rel="preload" href="./assets/js/75.eb7cfac9.js" as="script"><link rel="prefetch" href="./assets/js/10.a489e96f.js"><link rel="prefetch" href="./assets/js/11.f6f26a2f.js"><link rel="prefetch" href="./assets/js/12.8a827e29.js"><link rel="prefetch" href="./assets/js/13.e420b04a.js"><link rel="prefetch" href="./assets/js/14.52f00cc6.js"><link rel="prefetch" href="./assets/js/15.ef68d553.js"><link rel="prefetch" href="./assets/js/16.c2999dfd.js"><link rel="prefetch" href="./assets/js/17.0adb748c.js"><link rel="prefetch" href="./assets/js/18.2c077020.js"><link rel="prefetch" href="./assets/js/19.013b5e02.js"><link rel="prefetch" href="./assets/js/20.bb3b854e.js"><link rel="prefetch" href="./assets/js/21.28efc78c.js"><link rel="prefetch" href="./assets/js/22.4a1d71dd.js"><link rel="prefetch" href="./assets/js/23.605a5451.js"><link rel="prefetch" href="./assets/js/24.66bf035d.js"><link rel="prefetch" href="./assets/js/25.fbe72655.js"><link rel="prefetch" href="./assets/js/26.3f374d1f.js"><link rel="prefetch" href="./assets/js/27.556ea617.js"><link rel="prefetch" href="./assets/js/28.0cab868b.js"><link rel="prefetch" href="./assets/js/29.564f8747.js"><link rel="prefetch" href="./assets/js/3.4cfb1b9c.js"><link rel="prefetch" href="./assets/js/30.c4a099d1.js"><link rel="prefetch" href="./assets/js/31.7fbc3d2a.js"><link rel="prefetch" href="./assets/js/32.8f356b20.js"><link rel="prefetch" href="./assets/js/33.b5a1b0bb.js"><link rel="prefetch" href="./assets/js/34.57086c2e.js"><link rel="prefetch" href="./assets/js/35.2b4d0231.js"><link rel="prefetch" href="./assets/js/36.a99f6d64.js"><link rel="prefetch" href="./assets/js/37.eb25dcef.js"><link rel="prefetch" href="./assets/js/38.e45d8594.js"><link rel="prefetch" href="./assets/js/39.213e3a72.js"><link rel="prefetch" href="./assets/js/4.b86a0fbe.js"><link rel="prefetch" href="./assets/js/40.cadafdd6.js"><link rel="prefetch" href="./assets/js/41.23b0f26d.js"><link rel="prefetch" href="./assets/js/42.7c2b83c6.js"><link rel="prefetch" href="./assets/js/43.62f328ea.js"><link rel="prefetch" href="./assets/js/44.c4dfbd34.js"><link rel="prefetch" href="./assets/js/45.cde5bb22.js"><link rel="prefetch" href="./assets/js/46.6c62bdb8.js"><link rel="prefetch" href="./assets/js/47.4857766a.js"><link rel="prefetch" href="./assets/js/48.55a0cccc.js"><link rel="prefetch" href="./assets/js/49.3dceda91.js"><link rel="prefetch" href="./assets/js/5.13776f82.js"><link rel="prefetch" href="./assets/js/50.ab4d52fa.js"><link rel="prefetch" href="./assets/js/51.69ccc35a.js"><link rel="prefetch" href="./assets/js/52.01f3f711.js"><link rel="prefetch" href="./assets/js/53.c146a1ff.js"><link rel="prefetch" href="./assets/js/54.71ce70c2.js"><link rel="prefetch" href="./assets/js/55.98ef481d.js"><link rel="prefetch" href="./assets/js/56.b23daa51.js"><link rel="prefetch" href="./assets/js/57.6aa314ad.js"><link rel="prefetch" href="./assets/js/58.7d6367d9.js"><link rel="prefetch" href="./assets/js/59.88894cf5.js"><link rel="prefetch" href="./assets/js/6.93d89692.js"><link rel="prefetch" href="./assets/js/60.111f9a04.js"><link rel="prefetch" href="./assets/js/61.add82aab.js"><link rel="prefetch" href="./assets/js/62.8bfac830.js"><link rel="prefetch" href="./assets/js/63.db44a5ca.js"><link rel="prefetch" href="./assets/js/64.0244f0ef.js"><link rel="prefetch" href="./assets/js/65.2be994de.js"><link rel="prefetch" href="./assets/js/66.c5066e37.js"><link rel="prefetch" href="./assets/js/67.c11b474b.js"><link rel="prefetch" href="./assets/js/68.276bdc3e.js"><link rel="prefetch" href="./assets/js/69.f5f39d50.js"><link rel="prefetch" href="./assets/js/7.ca9f7e96.js"><link rel="prefetch" href="./assets/js/70.e3ca02b0.js"><link rel="prefetch" href="./assets/js/71.befcf8f7.js"><link rel="prefetch" href="./assets/js/72.04fabafd.js"><link rel="prefetch" href="./assets/js/73.e5b707f2.js"><link rel="prefetch" href="./assets/js/74.b5668150.js"><link rel="prefetch" href="./assets/js/76.c1b76370.js"><link rel="prefetch" href="./assets/js/77.5875e953.js"><link rel="prefetch" href="./assets/js/78.a5e2fa5b.js"><link rel="prefetch" href="./assets/js/79.eb2d51a7.js"><link rel="prefetch" href="./assets/js/8.570c39ea.js"><link rel="prefetch" href="./assets/js/80.7252ac50.js"><link rel="prefetch" href="./assets/js/81.eb980d26.js"><link rel="prefetch" href="./assets/js/82.9e069d8f.js"><link rel="prefetch" href="./assets/js/83.8c5a6dc6.js"><link rel="prefetch" href="./assets/js/84.26baaa09.js"><link rel="prefetch" href="./assets/js/85.96bc7e77.js"><link rel="prefetch" href="./assets/js/86.9c9dd1ca.js"><link rel="prefetch" href="./assets/js/87.d54639b8.js"><link rel="prefetch" href="./assets/js/88.3d3ae1e1.js"><link rel="prefetch" href="./assets/js/89.a81caa83.js"><link rel="prefetch" href="./assets/js/9.7a58df3d.js"><link rel="prefetch" href="./assets/js/90.c3c347ed.js"><link rel="prefetch" href="./assets/js/91.b6240032.js"><link rel="prefetch" href="./assets/js/92.8331718a.js"><link rel="prefetch" href="./assets/js/93.ca174cfa.js"><link rel="prefetch" href="./assets/js/94.fec3300c.js"><link rel="prefetch" href="./assets/js/95.076b06fb.js"><link rel="prefetch" href="./assets/js/96.8ed8b32f.js">
    <link rel="stylesheet" href="./assets/css/0.styles.cfdaa54c.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/./" class="home-link router-link-active"><!----> <span class="site-name"> zfy的个人博客</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="http://127.0.0.1:3002/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  自由博客板块
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="http://zfyangelo.gitee.io/yu-weather-web-show/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  天气预报
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="/./guide/" class="nav-link router-link-active">
  个人的学习笔记
</a></div><div class="nav-item"><a href="/./baodian/interview/" class="nav-link">
  项目及在校经历
</a></div><div class="nav-item"><a href="/./baodian/talk/" class="nav-link">
  爱好和联系方式
</a></div><div class="nav-item"><a href="https://gitee.com/zfyangelo" target="_blank" rel="noopener noreferrer" class="nav-link external">
  我的gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="http://127.0.0.1:3002/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  自由博客板块
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="http://zfyangelo.gitee.io/yu-weather-web-show/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  天气预报
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="/./guide/" class="nav-link router-link-active">
  个人的学习笔记
</a></div><div class="nav-item"><a href="/./baodian/interview/" class="nav-link">
  项目及在校经历
</a></div><div class="nav-item"><a href="/./baodian/talk/" class="nav-link">
  爱好和联系方式
</a></div><div class="nav-item"><a href="https://gitee.com/zfyangelo" target="_blank" rel="noopener noreferrer" class="nav-link external">
  我的gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>HTML</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>CSS</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Javascipt</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>HTML&amp;CSS练习</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>Javascipt练习</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/./guide/notes/jswork/01-认识javascript.html" class="sidebar-link">01-认识javaScript</a></li><li><a href="/./guide/notes/jswork/02-变量与数据类型.html" class="sidebar-link">02-变量与数据类型</a></li><li><a href="/./guide/notes/jswork/03-DOM.html" class="sidebar-link">03-DOM</a></li><li><a href="/./guide/notes/jswork/04-表达式和操作符.html" class="active sidebar-link">04-表达式和操作符</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/./guide/notes/jswork/05-判断.html" class="sidebar-link">05-判断</a></li><li><a href="/./guide/notes/jswork/06-循环.html" class="sidebar-link">06-循环</a></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>07-暂无</span> <span class="arrow right"></span></p> <!----></section></li><li><a href="/./guide/notes/jswork/08-函数.html" class="sidebar-link">08-函数</a></li><li><a href="/./guide/notes/jswork/09-案例.html" class="sidebar-link">09-案例</a></li><li><a href="/./guide/notes/jswork/10-数组.html" class="sidebar-link">10-数组</a></li><li><a href="/./guide/notes/jswork/11-字符串.html" class="sidebar-link">11-字符串</a></li><li><a href="/./guide/notes/jswork/12-DOM.html" class="sidebar-link">12-DOM</a></li><li><a href="/./guide/notes/jswork/13-浏览器操作.html" class="sidebar-link">13-BOM</a></li><li><a href="/./guide/notes/jswork/14-面向project.html" class="sidebar-link">14-面向对象</a></li><li><a href="/./guide/notes/jswork/15-Js阶段测试组卷.html" class="sidebar-link">15-Js阶段测试组卷</a></li><li><a href="/./guide/notes/jswork/16-模板字符串箭头函数变量声明.html" class="sidebar-link">16-模板字符串箭头函数变量声明</a></li><li><a href="/./guide/notes/jswork/17-解构赋值.html" class="sidebar-link">17-解构赋值</a></li><li><a href="/./guide/notes/jswork/18-project字面量增强和函数默认参数.html" class="sidebar-link">18-对象字面量增强和函数默认参数</a></li><li><a href="/./guide/notes/jswork/19-剩余参数和数组展开.html" class="sidebar-link">19-剩余参数和数组展开</a></li><li><a href="/./guide/notes/jswork/20-Map Set.html" class="sidebar-link">20-Map Set</a></li><li><a href="/./guide/notes/jswork/21-iterator和for...of循环.html" class="sidebar-link">21-iterator和for...of循环</a></li><li><a href="/./guide/notes/jswork/22-Promise和class.html" class="sidebar-link">22-Promise和class</a></li><li><a href="/./guide/notes/jswork/23-module.html" class="sidebar-link">23-module</a></li><li><a href="/./guide/notes/jswork/24-ES6测评题目.html" class="sidebar-link">24-ES6测评题目</a></li><li><a href="/./guide/notes/jswork/25-本地存储和http.html" class="sidebar-link">25-本地存储和http</a></li><li><a href="/./guide/notes/jswork/26-ajax选择题.html" class="sidebar-link">26-ajax选择题</a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h3 id="_1-以下表达式的计算结果为-选择一项"><a href="#_1-以下表达式的计算结果为-选择一项" class="header-anchor">#</a> 1.以下表达式的计算结果为？（选择一项）</h3> <p><img src="https://s1.ax1x.com/2020/09/14/wrgIht.png" alt="wrgIht.png"></p> <p>**A.**1</p> <p>**B.**19</p> <p>**C.**16</p> <p>**D.**0</p> <p><strong>本题考查运算符的优先级。</strong></p> <p>乘除法和取余的优先级高于加减法。但是加减法加上括号，优先级就会变最大。本题代码中，先分别计算4-1、6*2、5%2 。结果分别为3、12、1。然后再对结果进行相加，即3+12+1=16，<strong>所以本题答案为C。</strong></p> <h3 id="_2-math-pow-3-0-计算结果是-选择一项"><a href="#_2-math-pow-3-0-计算结果是-选择一项" class="header-anchor">#</a> 2.Math.pow(3,0)计算结果是？（选择一项）</h3> <p>**A.**1</p> <p>**B.**0</p> <p>**C.**3</p> <p>**D.**报错</p> <p><strong>本题考查幂的计算。</strong></p> <p>Math.pow(3,0)返回3的0次幂，任何数字的0次幂都等于1，<strong>所以本题答案为A。</strong></p> <h3 id="_3-以下代码-输出的结果是-选择一项"><a href="#_3-以下代码-输出的结果是-选择一项" class="header-anchor">#</a> 3.以下代码，输出的结果是？（选择一项）</h3> <p><img src="https://s1.ax1x.com/2020/09/14/wrRuIs.png" alt="wrRuIs.png"></p> <p>**A.**2,3</p> <p>**B.**3,2</p> <p>**C.**2,4</p> <p>**D.**3,3</p> <p><strong>本题考查向上取整和向下取整的运用。</strong></p> <p>Math.ceil是向上取整，2.1向上取整为3。</p> <p>Math.floor是向下取整，3.9向下取整为3。</p> <p>所以两次输出结果都为3，<strong>本题答案为D</strong></p> <h3 id="_4-数字5和字符串-5-进行加减乘除运算-结果是什么-选择一项"><a href="#_4-数字5和字符串-5-进行加减乘除运算-结果是什么-选择一项" class="header-anchor">#</a> 4.数字5和字符串&quot;5&quot;进行加减乘除运算，结果是什么？（选择一项）</h3> <p>**A.**10   0   25   1</p> <p>**B.**NaN  NaN NaN NaN</p> <p>**C.**55   0   25    1</p> <p>**D.**55   55  55   55</p> <p><strong>本题考察的是算数操作符。</strong></p> <p>在运算中，除了加法，其余的运算都会将字符串先转换为数字之后再进行计算，但是两个数据相加，如果有一方是字符串的话，加号的作用就是将他们进行拼接，所以数字5和字符串&quot;5&quot;进行加减乘除运算，结果分别是55,0,25,1。</p> <p><strong>本题答案为C。</strong></p> <h3 id="_5-下列关于比较操作符的描述正确的是-选择两项"><a href="#_5-下列关于比较操作符的描述正确的是-选择两项" class="header-anchor">#</a> 5.下列关于比较操作符的描述正确的是?（选择两项）</h3> <p><strong>A.</strong>==：相等，只比较数据类型是否相等</p> <p><strong>B.</strong>===：全等，比较值的同时比较数据类型是否相等</p> <p><strong>C.</strong>！=：不相等，比较值是否不相等</p> <p><strong>D.</strong>！==：不全等，只比较值是否不相等</p> <p><strong>本题考察的是比较操作符。</strong></p> <p>==：相等，只比较值是否相等，A中描述比较数据类型是否相等错误；</p> <p>===：全等，比较值的同时比较数据类型是否相等，B说法正确；</p> <p>！=：不相等，比较值是否不相等，C说法正确；</p> <p>！==：不全等，比较值的同时比较数据类型是否不相等，D描述只比较值是否不相等错误。</p> <p><strong>所以本题答案为BC。</strong></p> <h3 id="_6-代码在控制台的运行结果是-选择一项"><a href="#_6-代码在控制台的运行结果是-选择一项" class="header-anchor">#</a> 6.代码在控制台的运行结果是？（选择一项）</h3> <p><img src="https://s1.ax1x.com/2020/09/14/wrWOBD.png" alt="wrWOBD.png"></p> <p>**A.**true，false</p> <p>**B.**true，true</p> <p>**C.**false，true</p> <p>**D.**false，false</p> <p><strong>本题考察的是比较操作符。</strong></p> <p>==：相等，只比较值是否相等；===：相等，比较值的同时比较数据类型是否相等。a是数字10，b是字符串“10”，只比较数值的话，两者是相等的，即a==b返回true。但是它们的类型不相等，所以a===b返回false，<strong>本题答案为A。</strong></p> <h3 id="_7-代码在控制台输出的结果是-选择一项"><a href="#_7-代码在控制台输出的结果是-选择一项" class="header-anchor">#</a> 7.代码在控制台输出的结果是？（选择一项）</h3> <p><img src="https://s1.ax1x.com/2020/09/14/wrfGE4.png" alt="wrfGE4.png"></p> <p>**A.**time，0</p> <p>**B.**90，29</p> <p><strong>C.</strong>##，29</p> <p><strong>D.</strong>##，0</p> <p><strong>本题考察的是逻辑操作符。</strong></p> <p>1、多个操作数时，当所有操作数隐式转换都为true，则返回最后一个操作数。</p> <p>2、两个操作数时，如果第一个操作数隐式类型转换后为true，则返回下一个操作数；如果第一个操作数隐式类型转化后为false，则返回第一个操作数。</p> <p>本题代码中，“time&quot;、90、&quot;##&quot;三个操作数都可以转换为true，所以表达式“time&quot;&amp;&amp;90&amp;&amp;&quot;##&quot;返回true。0隐式转换后为false，所以表达式0&amp;&amp;result返回0。</p> <p><strong>本题答案为D。</strong></p> <h3 id="_8-代码在控制台输出的结果是-选择一项"><a href="#_8-代码在控制台输出的结果是-选择一项" class="header-anchor">#</a> 8.代码在控制台输出的结果是? （选择一项）</h3> <p><img src="https://s1.ax1x.com/2020/09/14/wrfjMV.png" alt="wrfjMV.png"></p> <p>**A.**null，NaN，undefined</p> <p>**B.**85，NaN，undefined</p> <p>**C.*<em>null，6</em>“ab”，a</p> <p>**D.*<em>85，6</em>“ab”，a</p> <p><strong>本题考察的是逻辑操作符。有以下几个比较重要的规则：</strong></p> <p>1、如果有一个操作数是null，则返回null。</p> <p>2、如果有一个操作数是NaN，则返回NaN。</p> <p>3、多个操作数时，当所有操作数都为真，则返回最后一个操作数。</p> <p>4、如果有一个操作数是undefined，则返回undefined。</p> <p>A中n&amp;&amp;sorce ，即null&amp;&amp;85返回null; B中sorce&amp;&amp;b&amp;&amp;6*&quot;ab&quot;，即85&amp;&amp;true&amp;&amp;NaN返回NaN;C中a&amp;&amp;true，即undefined&amp;&amp;true返回undefined。<strong>所以本题答案为A。</strong></p> <h3 id="_9-代码在控制台运行的结果是-选择一项"><a href="#_9-代码在控制台运行的结果是-选择一项" class="header-anchor">#</a> 9.代码在控制台运行的结果是？（选择一项）</h3> <p><img src="https://s1.ax1x.com/2020/09/14/wrhZqO.png" alt="wrhZqO.png"></p> <p>**A.**abc，0</p> <p>**B.**abc， 39</p> <p>**C.**abc，abc</p> <p>**D.**0，0</p> <p><strong>本题考察的是逻辑操作符或。</strong></p> <p>||（只要有一个条件成立，则返回true，反之则返回false），如果第一个操作数隐式类型转化后为true，则返回第一个操作数；如果第一个操作数隐式类型转化后为false，则返回第二个操作数；</p> <p>在第一句代码中，“abc” 隐式类型转化后为true，因此返回第一个操作数abc，在第二句代码中，0隐式类型转化后为false，因此返回第二个操作数abc。</p> <p><strong>所以本题答案为C。</strong></p> <h3 id="_10下面代码在控制台输出的结果是-选择一项"><a href="#_10下面代码在控制台输出的结果是-选择一项" class="header-anchor">#</a> 10下面代码在控制台输出的结果是？（选择一项）</h3> <p><img src="https://s1.ax1x.com/2020/09/14/wrhGsf.png" alt="wrhGsf.png"></p> <p><strong>A.</strong>“”，0，0</p> <p><strong>B.</strong>“”，NaN，0</p> <p>**C.**null，NaN，0</p> <p>**D.**null，NaN，undefined</p> <p><strong>本题考察的是逻辑操作符或。</strong></p> <p>||（只要有一个条件成立，则返回true，反之则返回false），如果所有的操作数返回的都是false ,那么就返回最后一个操作数 。这里面所有的操作数都是false，所以都是返回的最后一个操作数。</p> <h3 id="_11-代码的运行结果是-选择一项"><a href="#_11-代码的运行结果是-选择一项" class="header-anchor">#</a> 11.代码的运行结果是？（选择一项）</h3> <p><a href="https://imgchr.com/i/wrhgwF" target="_blank" rel="noopener noreferrer"><img src="https://s1.ax1x.com/2020/09/14/wrhgwF.png" alt="wrhgwF.png"><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p>**A.**true，0，1</p> <p>**B.**true，false，true</p> <p>**C.**true，false，1</p> <p>**D.**true，0，false</p> <p><strong>本题考察的是逻辑操作符非。</strong></p> <p>无论操作数是什么数据类型，逻辑非都会返回一个布尔值；!false取反是true，456本身是true，!456就是false，0是false，!0就是true。因此结果是true，false，true。</p> <h3 id="_12-下面代码的运行结果是-选择一项"><a href="#_12-下面代码的运行结果是-选择一项" class="header-anchor">#</a> 12.下面代码的运行结果是？（选择一项）</h3> <p><a href="https://imgchr.com/i/wrhIQx" target="_blank" rel="noopener noreferrer"><img src="https://s1.ax1x.com/2020/09/14/wrhIQx.png" alt="wrhIQx.png"><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p>**A.**12，42</p> <p>**B.**13，41</p> <p>**C.**13，42</p> <p>**D.**12，41</p> <p><strong>本题考察的是算数操作符与自增的综合运用。</strong></p> <p>其中，++num1，++在前，则会先自加再运算，因此var num3=++num1+num2 就等于13+29=42，因此num3=42，那么只要执行过这句代码（var num3=++num1+num2 ），num1就已经变成了13。所以num1=13，num3=42。</p> <h3 id="_13-下面代码的运行结果是-选择一项"><a href="#_13-下面代码的运行结果是-选择一项" class="header-anchor">#</a> 13.下面代码的运行结果是？（选择一项）</h3> <p><img src="https://s1.ax1x.com/2020/09/14/wr4kkQ.png" alt="wr4kkQ.png"></p> <p>**A.**3，13</p> <p>**B.**4，13</p> <p>**C.**3，14</p> <p>**D.**4，14</p> <p>**本题考察的是算数操作符与自增的综合运用。**其中，num2++，++在后，则会先运算，运算完之后再自增。</p> <p>因此var num3=num1+num2++ 就等于10+3=13，因此num3=13，但是执行过这句代码（var num3=num1+num2++）之后，num2才会变成4。所以num2=4，num3=13。</p> <h3 id="_14-观察如下代码-运行结果正确的选项是-选择一项"><a href="#_14-观察如下代码-运行结果正确的选项是-选择一项" class="header-anchor">#</a> 14.观察如下代码，运行结果正确的选项是 ? (选择一项）</h3> <p><img src="https://s1.ax1x.com/2020/09/15/wytH3j.png" alt="wytH3j.png"></p> <p>**A.**3，5，8</p> <p>**B.**2，5，7</p> <p>**C.**2，4，8</p> <p>**D.**2，4，7</p> <p><strong>本题考察的是算数操作符与自减的综合运用。</strong></p> <p>--在前会先自减再运算，--在后会先运算再自减。因此var num3=--num1+num2--就等于num3=2+5=7，即num3=7。运算完之后，num1和num2的值都会-1，即num1=2，num2=4。<strong>所以本题答案为D</strong>。</p> <h3 id="_15-代码在控制台的运行结果是-选择一项"><a href="#_15-代码在控制台的运行结果是-选择一项" class="header-anchor">#</a> 15.代码在控制台的运行结果是？（选择一项）</h3> <p><img src="https://s1.ax1x.com/2020/09/15/wy4jUS.png" alt="wy4jUS.png"></p> <p>**A.**24，true</p> <p>**B.**24，false</p> <p>**C.**30，true</p> <p>**D.**30，false</p> <p><strong>本题考察的是赋值运算符以及比较操作符。</strong></p> <p>a+=12意思是a的值加上12再赋值给a，即a=a+12=22; b%=3意思是把b除以3的余数赋值给b，20除以3的余数为2，,即b=2；那么a+b=24，a&gt;b。输出的结果24，true，<strong>所以本题答案为A。</strong></p> <h3 id="_16-代码在控制台的运行结果是-选择一项"><a href="#_16-代码在控制台的运行结果是-选择一项" class="header-anchor">#</a> 16.代码在控制台的运行结果是？（选择一项）</h3> <p><img src="https://s1.ax1x.com/2020/09/15/wyNTZ6.png" alt="wyNTZ6.png"></p> <p>**A.**hello云牧帅逼，30</p> <p>**B.**hello 云牧帅逼，30</p> <p>**C.**hello云牧帅逼，11</p> <p>**D.**hello 云牧帅逼，11</p> <p><strong>本题考察的是赋值操作符。</strong></p> <p>a+=b相当于a=a+b，即a=30；str+=”云牧帅逼”相当于str=str+&quot;云牧帅逼&quot;，即str= hello 云牧帅逼。所以输出的结果为hello 云牧帅逼，30，<strong>本题答案为B</strong></p> <h3 id="_17-代码在控制台输出的结果是-选择一项"><a href="#_17-代码在控制台输出的结果是-选择一项" class="header-anchor">#</a> 17.代码在控制台输出的结果是？（选择一项）</h3> <p><a href="https://imgchr.com/i/wyawBq" target="_blank" rel="noopener noreferrer"><img src="https://s1.ax1x.com/2020/09/15/wyawBq.png" alt="wyawBq.png"><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p>**A.**false，true</p> <p>**B.**true， false</p> <p>**C.**false，false</p> <p>**D.**true，true</p> <p><strong>本题考察的是逻辑操作符与。</strong></p> <p>逻辑与（&amp;&amp;）表达式中，只要有一个条件不成立，则返回false。第一个输出语句中，sorce&gt;result是成立的，num&lt;result是不成立的，所以第一句返回false。第二个输出语句中，sorce&gt;num和result&lt;num都成立，所以第二句返回true。</p> <p><strong>本题答案为A。</strong></p> <h3 id="_18-代码在控制台输出的结果是-选择一项"><a href="#_18-代码在控制台输出的结果是-选择一项" class="header-anchor">#</a> 18.代码在控制台输出的结果是？（选择一项）</h3> <p><img src="https://s1.ax1x.com/2020/09/15/wyd9PS.png" alt="wyd9PS.png"></p> <p>**A.**false，true</p> <p>**B.**true， false</p> <p>**C.**false，false</p> <p>**D.**true，true</p> <p><strong>本题考察的是逻辑操作符或。</strong></p> <p>逻辑或（||）表达式中，只要有一个条件成立，则返回true，所有条件都不成立则返回false。第一个输出语句中，55&gt;78不成立，但45&lt;58成立，因此返回true；第二个输出语句中，43&gt;68和45&lt;24都不成立，因此返回false。</p> <p><strong>本题答案为B。</strong></p> <h3 id="_19-现在有两个变量-分别为a-5和b-7-我们通过第三个变量c作为中介-交换两个变量的值。"><a href="#_19-现在有两个变量-分别为a-5和b-7-我们通过第三个变量c作为中介-交换两个变量的值。" class="header-anchor">#</a> 19.现在有两个变量，分别为a=5和b=7,我们通过第三个变量c作为中介，交换两个变量的值。</h3> <ol><li>定义一个变量c，把a赋值给c。</li> <li>然后把b赋值给a，再把c赋值给b。</li> <li>最后输出a和b交换之后的结果。</li></ol> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span><span class="token punctuation">&gt;</span></span><span class="token script"><span class="token language-javascript">
		<span class="token keyword">let</span> a <span class="token operator">=</span> <span class="token number">666</span><span class="token punctuation">;</span>
		<span class="token keyword">let</span> b <span class="token operator">=</span> <span class="token number">999</span><span class="token punctuation">;</span>

		<span class="token keyword">let</span> temp<span class="token punctuation">;</span>

		temp <span class="token operator">=</span> a<span class="token punctuation">;</span>

		a <span class="token operator">=</span> b<span class="token punctuation">;</span>

		b <span class="token operator">=</span> temp<span class="token punctuation">;</span>

		console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>a <span class="token punctuation">,</span> b<span class="token punctuation">)</span><span class="token punctuation">;</span>
	</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><h3 id="_20-编码练习"><a href="#_20-编码练习" class="header-anchor">#</a> 20.编码练习</h3> <p><img src="https://s1.ax1x.com/2020/09/15/wyDo1U.gif" alt="wyDo1U.gif"></p> <h3 id="_21-编码练习"><a href="#_21-编码练习" class="header-anchor">#</a> 21.编码练习</h3> <p><img src="https://s1.ax1x.com/2020/09/15/wyr8Nq.gif" alt="wyr8Nq.gif"></p> <div class="language-html line-numbers-mode"><pre class="language-html"><code>  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>style</span><span class="token punctuation">&gt;</span></span><span class="token style"><span class="token language-css">
      <span class="token selector">*</span> <span class="token punctuation">{</span>
        <span class="token property">margin</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
        <span class="token property">padding</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
        <span class="token property">list-style-type</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span>
      <span class="token punctuation">}</span>

      <span class="token selector">#wrap</span> <span class="token punctuation">{</span>
        <span class="token property">width</span><span class="token punctuation">:</span> 500px<span class="token punctuation">;</span>
        <span class="token property">margin</span><span class="token punctuation">:</span> 50px auto<span class="token punctuation">;</span>
      <span class="token punctuation">}</span>

      <span class="token selector">#text</span> <span class="token punctuation">{</span>
        <span class="token property">width</span><span class="token punctuation">:</span> 100%<span class="token punctuation">;</span>
        <span class="token property">height</span><span class="token punctuation">:</span> 100px<span class="token punctuation">;</span>
        <span class="token property">border</span><span class="token punctuation">:</span> 1px solid #000<span class="token punctuation">;</span>
        <span class="token property">resize</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span>
        <span class="token comment">/* 让textarea不可以调整大小 */</span>
      <span class="token punctuation">}</span>

      <span class="token selector">#btn</span> <span class="token punctuation">{</span>
        <span class="token property">float</span><span class="token punctuation">:</span> right<span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
      <span class="token selector">#list</span> <span class="token punctuation">{</span>
        <span class="token property">width</span><span class="token punctuation">:</span> 100%<span class="token punctuation">;</span>
        <span class="token property">margin-top</span><span class="token punctuation">:</span> 30px<span class="token punctuation">;</span>
      <span class="token punctuation">}</span>

      <span class="token selector">#list li</span> <span class="token punctuation">{</span>
        <span class="token property">width</span><span class="token punctuation">:</span> 100%<span class="token punctuation">;</span>
        <span class="token property">line-height</span><span class="token punctuation">:</span> 22px<span class="token punctuation">;</span>
        <span class="token property">font-size</span><span class="token punctuation">:</span> 14px<span class="token punctuation">;</span>
        <span class="token property">color</span><span class="token punctuation">:</span> #333<span class="token punctuation">;</span>
        <span class="token property">text-indent</span><span class="token punctuation">:</span> 2em<span class="token punctuation">;</span>
        <span class="token property">padding</span><span class="token punctuation">:</span> 10px 0<span class="token punctuation">;</span>
        <span class="token property">border-bottom</span><span class="token punctuation">:</span> 1px dotted #999<span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
    </span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>style</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>head</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>body</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>wrap<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>textarea</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>text<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>textarea</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>button<span class="token punctuation">&quot;</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>btn<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>提交<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>ul</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>list<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>li</span><span class="token punctuation">&gt;</span></span>1111<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>li</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>ul</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span><span class="token punctuation">&gt;</span></span><span class="token script"><span class="token language-javascript">
      <span class="token keyword">let</span> oBtn <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span><span class="token string">&quot;btn&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
        oArea <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span><span class="token string">&quot;text&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
        oList <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span><span class="token string">&quot;list&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

      oBtn<span class="token punctuation">.</span><span class="token function-variable function">onclick</span> <span class="token operator">=</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">let</span> val <span class="token operator">=</span> oArea<span class="token punctuation">.</span>value<span class="token punctuation">;</span>
        <span class="token comment">// console.log(val);</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>val<span class="token punctuation">)</span> <span class="token punctuation">{</span>
          oList<span class="token punctuation">.</span>innerHTML <span class="token operator">+=</span> <span class="token string">&quot;&lt;li&gt;&quot;</span> <span class="token operator">+</span> val <span class="token operator">+</span> <span class="token string">&quot;&lt;/li&gt;&quot;</span><span class="token punctuation">;</span>
          oArea<span class="token punctuation">.</span>value <span class="token operator">=</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
      <span class="token punctuation">}</span><span class="token punctuation">;</span>
    </span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br></div></div><h3 id="_22-编码练习"><a href="#_22-编码练习" class="header-anchor">#</a> 22.编码练习</h3> <p><img src="https://s1.ax1x.com/2020/09/15/wyro5t.gif" alt="wyro5t.gif"></p> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>style</span><span class="token punctuation">&gt;</span></span><span class="token style"><span class="token language-css">
      <span class="token selector">*</span> <span class="token punctuation">{</span>
        <span class="token property">margin</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
        <span class="token property">padding</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
      <span class="token selector">table</span> <span class="token punctuation">{</span>
        <span class="token property">width</span><span class="token punctuation">:</span> 500px<span class="token punctuation">;</span>
        <span class="token property">border-collapse</span><span class="token punctuation">:</span> collapse<span class="token punctuation">;</span>
        <span class="token property">margin</span><span class="token punctuation">:</span> 50px auto 0<span class="token punctuation">;</span>
      <span class="token punctuation">}</span>

      <span class="token selector">td,
      th</span> <span class="token punctuation">{</span>
          
        <span class="token property">height</span><span class="token punctuation">:</span> 50px<span class="token punctuation">;</span>
        <span class="token property">border</span><span class="token punctuation">:</span> 1px solid black<span class="token punctuation">;</span>
        <span class="token property">user-select</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span>
        <span class="token property">text-align</span><span class="token punctuation">:</span> center<span class="token punctuation">;</span>
      <span class="token punctuation">}</span>

      <span class="token selector">th</span> <span class="token punctuation">{</span>
        <span class="token property">height</span><span class="token punctuation">:</span> 30px<span class="token punctuation">;</span>
      <span class="token punctuation">}</span>

      <span class="token selector">td span</span> <span class="token punctuation">{</span>
        <span class="token property">display</span><span class="token punctuation">:</span> inline-block<span class="token punctuation">;</span>
        <span class="token property">width</span><span class="token punctuation">:</span> 30px<span class="token punctuation">;</span>
        <span class="token property">height</span><span class="token punctuation">:</span> 30px<span class="token punctuation">;</span>
        <span class="token property">line-height</span><span class="token punctuation">:</span> 30px<span class="token punctuation">;</span>
        <span class="token property">text-align</span><span class="token punctuation">:</span> center<span class="token punctuation">;</span>
        <span class="token property">background-color</span><span class="token punctuation">:</span> #666<span class="token punctuation">;</span>
        <span class="token property">color</span><span class="token punctuation">:</span> #fff<span class="token punctuation">;</span>
        <span class="token property">cursor</span><span class="token punctuation">:</span> pointer<span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
    </span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>style</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>head</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>body</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>table</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>tr</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>th</span><span class="token punctuation">&gt;</span></span>图片<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>th</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>th</span><span class="token punctuation">&gt;</span></span>单价<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>th</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>th</span><span class="token punctuation">&gt;</span></span>数量<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>th</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>th</span><span class="token punctuation">&gt;</span></span>价格<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>th</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>tr</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>tr</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>td</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>img<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>./1.jpg<span class="token punctuation">&quot;</span></span> <span class="token attr-name">alt</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span><span class="token punctuation">&quot;</span></span> <span class="token attr-name">width</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>50px<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>td</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>td</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>unit-price<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>20<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>td</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>td</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>quantity<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>sub<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>-<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">&gt;</span></span>
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>number<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">&gt;</span></span>
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>add<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>+<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>td</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>td</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>price<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>td</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>tr</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>table</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span><span class="token punctuation">&gt;</span></span>
      let oSub = document.getElementById(&quot;sub&quot;);
      let oAdd = document.getElementById(&quot;add&quot;);
      let oNum = document.getElementById(&quot;number&quot;);
      let oPrice = document.getElementById(&quot;price&quot;);
      let unit_price = document.getElementById(&quot;unit-price&quot;);

      oAdd.onclick = function () {
        let current = oNum.innerText;

        current++;

        oNum.innerText = current;

		let p = current * unit_price.innerText;
		
        oPrice.innerText = p;
      };

      oSub.onclick = function () {
        let current = oNum.innerText;

        current--;

        // if (current &lt; 0) {
        //   current = 0;
        // }

        if (current &gt;= 0) {
          oNum.innerText = current;

		  let p = current * unit_price.innerText;
		  
          oPrice.innerText = p;
        }
      };
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br><span class="line-number">80</span><br><span class="line-number">81</span><br><span class="line-number">82</span><br><span class="line-number">83</span><br><span class="line-number">84</span><br><span class="line-number">85</span><br><span class="line-number">86</span><br><span class="line-number">87</span><br><span class="line-number">88</span><br><span class="line-number">89</span><br><span class="line-number">90</span><br><span class="line-number">91</span><br></div></div></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/./guide/notes/jswork/03-DOM.html" class="prev">
        03-DOM
      </a></span> <span class="next"><a href="/./guide/notes/jswork/05-判断.html">
        05-判断
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"><!----><div class="reco-bgm-panel" data-v-b1d3339e><audio id="bgm" src="https://www.ytmp3.cn/down/75475.mp3" data-v-b1d3339e></audio> <div class="reco-float-box" style="bottom:30px;z-index:999999;display:none;" data-v-b1d3339e data-v-41bcba48 data-v-b1d3339e><img src="https://p1.music.126.net/qTSIZ27qiFvRoKj-P30BiA==/109951165895951287.jpg?param=200y200" data-v-b1d3339e></div> <div class="reco-bgm-box" style="left:10px;bottom:10px;z-index:999999;" data-v-b1d3339e data-v-41bcba48 data-v-b1d3339e><div class="reco-bgm-cover" style="background-image:url(https://p1.music.126.net/qTSIZ27qiFvRoKj-P30BiA==/109951165895951287.jpg?param=200y200);" data-v-b1d3339e><div class="mini-operation" style="display:none;" data-v-b1d3339e><i class="reco-bgm reco-bgm-pause" style="display:none;" data-v-b1d3339e></i> <i class="reco-bgm reco-bgm-play" style="display:none;" data-v-b1d3339e></i></div> <div class="falut-message" style="display:none;" data-v-b1d3339e>
          播放失败
        </div></div> <div class="reco-bgm-info" data-v-b1d3339e data-v-41bcba48 data-v-b1d3339e><div class="info-box" data-v-b1d3339e><i class="reco-bgm reco-bgm-music music" data-v-b1d3339e></i>花花公子</div> <div class="info-box" data-v-b1d3339e><i class="reco-bgm reco-bgm-artist" data-v-b1d3339e></i>马思唯/step.jad</div> <div class="reco-bgm-progress" data-v-b1d3339e><div class="progress-bar" data-v-b1d3339e><div class="bar" data-v-b1d3339e></div></div></div> <div class="reco-bgm-operation" data-v-b1d3339e><i class="reco-bgm reco-bgm-last last" data-v-b1d3339e></i> <i class="reco-bgm reco-bgm-pause pause" style="display:none;" data-v-b1d3339e></i> <i class="reco-bgm reco-bgm-play play" data-v-b1d3339e></i> <i class="reco-bgm reco-bgm-next next" data-v-b1d3339e></i> <i class="reco-bgm reco-bgm-volume1 volume" data-v-b1d3339e></i> <i class="reco-bgm reco-bgm-mute mute" style="display:none;" data-v-b1d3339e></i> <div class="volume-bar" data-v-b1d3339e><div class="bar" data-v-b1d3339e></div></div></div></div> <div class="reco-bgm-left-box" data-v-b1d3339e data-v-41bcba48 data-v-b1d3339e><i class="reco-bgm reco-bgm-left" data-v-b1d3339e></i></div></div></div></div></div>
    <script src="./assets/js/app.7878252f.js" defer></script><script src="./assets/js/2.877879cc.js" defer></script><script src="./assets/js/75.eb7cfac9.js" defer></script>
  </body>
</html>
